{extend name='public/base' /}
{block name='content'}
{include file='public/content_header' /}
<section class="content">
    <div class="row">
        <div class="col-md-12">
            <div class="box box-primary">
                <!-- 表单头部 -->
                <div class="box-header with-border">
                    <div class="btn-group">
                        <a class="btn flat btn-sm btn-default BackButton">
                            <i class="fa fa-arrow-left"></i>
                            返回
                        </a>
                    </div>
                </div>
                <!-- 表单 -->
                <form id="dataForm" class="form-horizontal dataForm" action="" method="post" onkeydown="if(event.keyCode===13){return false;}">
                    <!-- 表单字段区域 -->
                    <div class="box-body">
                        <div class="form-group">
                            <label for="name" class="col-sm-2 control-label">姓名</label>
                            <div class="col-sm-10 col-md-4">
                                <input id="name" name="name" value="{$data.name|default=''}" placeholder="请输入姓名"
                                       type="text" class="form-control field-text" autocomplete="off">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="position_id" class="col-sm-2 control-label">职位</label>
                            <div class="col-sm-10 col-md-4">
                                <select name="position_id" id="position_id" class="form-control field-select"
                                        data-placeholder="请选择职位">
                                    <option value=""></option>
                                    {foreach name='position_list' id='item'}
                                    <option value="{$item.id}" {if isset($data) &&
                                            $data.position_id==$item.id}selected{/if}>
                                        {$item.name}
                                    </option>
                                    {/foreach}
                                </select>
                            </div>
                        </div>
                        <script>
                            $('#position_id').select2();
                            $("#position_id").change(function() {
                                $("#position_id-error").hide();
                            });
                        </script>

                        <div class="form-group">
                            <label for="insure_id" class="col-sm-2 control-label">社保关系</label>
                            <div class="col-sm-10 col-md-4">
                                <select name="insure_id" id="insure_id" class="form-control field-select"
                                        data-placeholder="请选择社保关系">
                                    <option value=""></option>
                                    {foreach name='insure' id='item'}
                                    <option value="{$item.id}" {if isset($data) &&
                                            $data.insure_id==$item.id}selected{/if}>
                                        {$item.insure}
                                    </option>
                                    {/foreach}
                                </select>
                            </div>
                        </div>
                        <script>
                            $('#insure_id').select2();
                            $("#insure_id").change(function() {
                                $("#insure_id-error").hide();
                            });
                        </script>

                        <div class="form-group">
                            <label for="job_number" class="col-sm-2 control-label">档案编号</label>
                            <div class="col-sm-10 col-md-4">
                                <input id="job_number" name="job_number" value="{$data.job_number|default=''}"
                                       placeholder="请输入档案编号" type="text" class="form-control field-text" autocomplete="off">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="mobile" class="col-sm-2 control-label">手机号</label>
                            <div class="col-sm-10 col-md-4">
                                <input id="mobile" name="mobile" value="{$data.mobile|default=''}" placeholder="请输入手机号"
                                       type="tel" maxlength="11" class="form-control field-mobile">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="email" class="col-sm-2 control-label">邮箱</label>
                            <div class="col-sm-10 col-md-4">
                                <input id="email" name="email" value="{$data.email|default=''}" placeholder="请输入邮箱"
                                       type="email" class="form-control field-text" >
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="department_id" class="col-sm-2 control-label">部门</label>
                            <div class="col-sm-10 col-md-4">
                                <select name="department_id" id="department_id" class="form-control field-select"
                                        data-placeholder="请选择部门">
                                    <option value=""></option>
                                    {$department_list|raw}
                                </select>
                            </div>
                        </div>
                        <script>
                            $('#department_id').select2();
                            $("#department_id").change(function() {
                                $("#department_id-error").hide();
                            });
                        </script>
                        <div class="form-group">
                            <label for="insurance_types" class="col-sm-2 control-label">险种</label>
                            <div class="col-sm-10 col-md-4">
                                <input id="insurance_types" name="insurance_types"
                                       value="{$data.insurance_types|default=''}" placeholder="请输入险种" type="text"
                                       class="form-control field-text" autocomplete="on">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="id_card" class="col-sm-2 control-label">身份证号</label>
                            <div class="col-sm-10 col-md-4">
                                <input id="id_card" name="id_card" value="{$data.id_card|default=''}"
                                       placeholder="请输入身份证号" type="text" maxlength="18"
                                       class="form-control field-id-card" autocomplete="off">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="id_card" class="col-sm-2 control-label">性别</label>
                            <div class="radio col-sm-10 col-md-4">
                                <label>
                                    <input type="radio" name="sex" value="1" {if isset($data)&& $data.sex=="1"}checked{/if}>
                                    男
                                </label>
                                <label>
                                    <input type="radio" name="sex" value="0"  {if isset($data)&& $data.sex=="0"}checked{/if}>
                                    女
                                </label>
                            </div>
                        </div>

                        <div class="form-group">
                            <label for="age" class="col-sm-2 control-label">年龄</label>
                            <div class="col-sm-10 col-md-4">
                                <div class="input-group">
                                    <input id="age" name="age" value="{$data.age|default=''}" placeholder="请输入年龄"
                                           type="number" class="form-control field-number">
                                </div>
                            </div>
                        </div>
<!--                        <script>-->
<!--                            $('#age')-->
<!--                                .bootstrapNumber({-->
<!--                                    upClass: 'success',-->
<!--                                    downClass: 'primary',-->
<!--                                    center: true-->
<!--                                });-->
<!--                        </script>-->
                        <div class="form-group">
                            <label for="birthday" class="col-sm-2 control-label">生日</label>
                            <div class="col-sm-10 col-md-4">
                                <input id="birthday" name="birthday" value="{$data.birthday|default=''}"
                                       placeholder="请选择生日" type="text" class="form-control filed-date" autocomplete="off">
                            </div>
                        </div>
                        <script>
                            laydate.render({
                                elem: '#birthday',
                                btns:[],
                                ready: function (date) {
                                    $(".layui-laydate").on('click', 'ul li', function () {
                                        $(".layui-laydate").remove();
                                    });
                                },
                                change: function (value) {
                                    $("#birthday").val(value);
                                },
                            });
                        </script>
                        <div class="form-group">
                            <label for="birthday_month" class="col-sm-2 control-label">生日月份</label>
                            <div class="col-sm-10 col-md-4">
                                <div class="input-group">
                                    <input id="birthday_month" name="birthday_month"
                                           value="{$data.birthday_month|default=''}" placeholder="请输入生日月份" type="number"
                                           class="form-control field-number">
                                </div>
                            </div>
                        </div>
<!--                        <script>-->
<!--                            $('#birthday_month')-->
<!--                                .bootstrapNumber({-->
<!--                                    upClass: 'success',-->
<!--                                    downClass: 'primary',-->
<!--                                    center: true-->
<!--                                });-->
<!--                        </script>-->
                        <div class="form-group">
                            <label for="node_type" class="col-sm-2 control-label">户口类型</label>
                            <div class="col-sm-10 col-md-4">
                                <input id="node_type" name="node_type" value="{$data.node_type|default=''}"
                                       placeholder="请输入户口类型" type="text" class="form-control field-text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="nation" class="col-sm-2 control-label">民族</label>
                            <div class="col-sm-10 col-md-4">
                                <input id="nation" name="nation" value="{$data.nation|default=''}" placeholder="请输入民族"
                                       type="text" class="form-control field-text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="hired_date" class="col-sm-2 control-label">入职日期</label>
                            <div class="col-sm-10 col-md-4">
                                <input id="hired_date" name="hired_date" value="{if isset($data) && $data.hired_date=='0000-00-00'}{else}{$data.hired_date|default=''}{/if}"
                                       placeholder="请选择入职日期" type="text" class="form-control filed-date" autocomplete="off">
                            </div>
                        </div>
                        <script>
                            laydate.render({
                                elem: '#hired_date',
                                btns:[],
                                ready: function (date) {
                                    $(".layui-laydate").on('click', 'ul li', function () {
                                        $(".layui-laydate").remove();
                                    });
                                },
                                change: function (value) {
                                    $("#hired_date").val(value);
                                },
                                done:function (value,date) {
                                    let day = date.date;
                                    let trial_month = $('#trial_month').val();
                                    if (trial_month !=''){
                                        let dates = getMonthBeforeFormatAndDay(value,trial_month,'-',day);
                                        $('#full_date').val(dates);
                                    }
                                    let trial_salary_month = $('#trial_salary_month').val();
                                    if (trial_salary_month !=''){
                                        let dates = getMonthBeforeFormatAndDay(value,trial_salary_month,'-',day);
                                        $('#full_salary_date').val(dates);
                                    }
                                }
                            });
                        </script>
                        <div class="form-group">
                            <label for="trial_month" class="col-sm-2 control-label">试用月数</label>
                            <div class="col-sm-10 col-md-4">
                                <div class="input-group">
                                    <input id="trial_month" name="trial_month" value="{$data.trial_month|default=''}"
                                           placeholder="请输入试用月数" type="number" class="form-control field-number">
                                </div>
                            </div>
                        </div>
                        <script>
                            // $('#trial_month')
                            //     .bootstrapNumber({
                            //         upClass: 'success',
                            //         downClass: 'primary',
                            //         center: true
                            //     });
                            $('#trial_month').change(function () {
                                let hired_date = $('#hired_date').val();
                                if (hired_date !=''){
                                    let date = hired_date.substring(8,10);
                                    let dates = getMonthBeforeFormatAndDay(hired_date,$(this).val(),'-',date);
                                    $('#full_date').val(dates);
                                }
                            })
                        </script>
                        <div class="form-group">
                            <label for="full_date" class="col-sm-2 control-label">转正日期</label>
                            <div class="col-sm-10 col-md-4">
                                <input id="full_date" name="full_date" value="{if isset($data) &&  $data.full_date=='0000-00-00'}{else}{$data.full_date|default=''}{/if}"
                                       placeholder="请选择转正日期" type="text" class="form-control filed-date" autocomplete="off">
                            </div>
                        </div>
                        <script>
                            laydate.render({
                                elem: '#full_date',
                                btns:[],
                                ready: function (date) {
                                    $(".layui-laydate").on('click', 'ul li', function () {
                                        $(".layui-laydate").remove();
                                    });
                                },
                                change: function (value) {
                                    $("#full_date").val(value);
                                },
                            });
                        </script>
                        <div class="form-group">
                            <label for="trial_salary_month" class="col-sm-2 control-label">试用薪资月数</label>
                            <div class="col-sm-10 col-md-4">
                                <div class="input-group">
                                    <input id="trial_salary_month" name="trial_salary_month" value="{$data.trial_salary_month|default=''}" placeholder="请输入试用薪资月数" type="number" class="form-control field-number">
                                </div>
                            </div>
                        </div>
                        <script>
                            // $('#trial_salary_month')
                            //     .bootstrapNumber({
                            //         upClass: 'success',
                            //         downClass: 'primary',
                            //         center: true
                            //     });
                            $('#trial_salary_month').change(function () {
                                let hired_date = $('#hired_date').val();
                                if (hired_date !=''){
                                    let date = hired_date.substring(8,10);
                                    let dates = getMonthBeforeFormatAndDay(hired_date,$(this).val(),'-',date);
                                    $('#full_salary_date').val(dates);
                                }
                            })
                        </script>

                        <div class="form-group">
                            <label for="full_salary_date" class="col-sm-2 control-label">转正薪资日期</label>
                            <div class="col-sm-10 col-md-4">
                                <input id="full_salary_date" name="full_salary_date"
                                       value="{if isset($data) &&  $data.full_salary_date=='0000-00-00'}{else}{$data.full_salary_date|default=''}{/if}" placeholder="请选择转正薪资日期" type="text"
                                       class="form-control filed-date" autocomplete="off">
                            </div>
                        </div>
                        <script>
                            laydate.render({
                                elem: '#full_salary_date',
                                btns:[],
                                ready: function (date) {
                                    $(".layui-laydate").on('click', 'ul li', function () {
                                        $(".layui-laydate").remove();
                                    });
                                },
                                change: function (value) {
                                    $("#full_salary_date").val(value);
                                },
                            });
                        </script>
                        <div class="form-group">
                            <label for="contract_start_date" class="col-sm-2 control-label">合同开始日期</label>
                            <div class="col-sm-10 col-md-4">
                                <input id="contract_start_date" name="contract_start_date"
                                       value="{if isset($data) &&  $data.contract_start_date=='0000-00-00'}{else}{$data.contract_start_date|default=''}{/if}" placeholder="请选择合同开始日期"
                                       type="text" class="form-control filed-date" autocomplete="off">
                            </div>
                        </div>
                        <script>
                            laydate.render({
                                elem: '#contract_start_date',
                                btns:[],
                                ready: function (date) {
                                    $(".layui-laydate").on('click', 'ul li', function () {
                                        $(".layui-laydate").remove();
                                    });
                                },
                                change: function (value) {
                                    $("#contract_start_date").val(value);
                                },
                                done:function (value,date) {
                                    let contract_times = $('#contract_times').val();
                                    if (contract_times !=''){
                                        let year = value.substring(0,4);
                                        let date = value.substring(4,10);
                                        let endyear = parseInt(year)+parseInt(contract_times);
                                        let enddate = endyear + date;
                                        $('#contract_end_date').val(enddate);
                                    }
                                }
                            });
                        </script>
                        <div class="form-group">
                            <label for="contract_times" class="col-sm-2 control-label">合同期限（年）</label>
                            <div class="col-sm-10 col-md-4">
                                <div class="input-group">
                                    <input id="contract_times" name="contract_times"
                                           value="{$data.contract_times|default=''}" placeholder="请输入合同期限（年）"
                                           type="number" class="form-control field-number">
                                </div>
                            </div>
                        </div>
                        <script>
                            // $('#contract_times')
                            //     .bootstrapNumber({
                            //         upClass: 'success',
                            //         downClass: 'primary',
                            //         center: true
                            //     });
                            $('#contract_times').change(function () {
                                let contract_start_date = $('#contract_start_date').val();
                                if (contract_start_date !=''){
                                    let year = contract_start_date.substring(0,4);
                                    let date = contract_start_date.substring(4,10);
                                    let endyear = parseInt(year)+parseInt($(this).val());
                                    let enddate = endyear + date;
                                    $('#contract_end_date').val(enddate);
                                }
                            })
                        </script>
                        <div class="form-group">
                            <label for="contract_end_date" class="col-sm-2 control-label">合同结束日期</label>
                            <div class="col-sm-10 col-md-4">
                                <input id="contract_end_date" name="contract_end_date"
                                       value="{if isset($data) &&  $data.contract_end_date=='0000-00-00'}{else}{$data.contract_end_date|default=''}{/if}" placeholder="请选择合同结束日期" type="text"
                                       class="form-control filed-date" autocomplete="off">
                            </div>
                        </div>
                        <script>
                            laydate.render({
                                elem: '#contract_end_date',
                                btns:[],
                                ready: function (date) {
                                    $(".layui-laydate").on('click', 'ul li', function () {
                                        $(".layui-laydate").remove();
                                    });
                                },
                                change: function (value) {
                                    $("#contract_end_date").val(value);
                                },
                            });
                        </script>

                        <div class="form-group">
                            <label for="is_leader" class="col-sm-2 control-label">是否部门领导</label>
                            <div class="col-sm-10 col-md-4">
                                <input class="input-switch" id="is_leader" value="1" {if(!isset($data)
                                       ||$data.is_leader==1)}checked{/if} type="checkbox"/>
                                <input class="switch field-switch" placeholder="是否部门领导" name="is_leader"
                                       value="{$data.is_leader|default='0'}" hidden/>
                            </div>
                        </div>

                        <script>
                            $('#is_leader').bootstrapSwitch({
                                onText: "是",
                                offText: "否",
                                onColor: "success",
                                offColor: "danger",
                                onSwitchChange: function (event, state) {
                                    $(event.target).closest('.bootstrap-switch').next().val(state ? '1' : '0').change();
                                }
                            });
                        </script>
                        <div class="form-group">
                            <label for="sort_number" class="col-sm-2 control-label">排序</label>
                            <div class="col-sm-10 col-md-4">
                                <input id="sort_number" name="sort_number" value="{$data.sort_number|default='0'}"
                                       placeholder="请输入排序" type="text" class="form-control field-text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="emergency_contact" class="col-sm-2 control-label">紧急联系人</label>
                            <div class="col-sm-10 col-md-4">
                                <input id="emergency_contact" name="emergency_contact"
                                       value="{$data.emergency_contact|default=''}" placeholder="请输入紧急联系人" type="text"
                                       class="form-control field-text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="emergency_contact_relation" class="col-sm-2 control-label">与本人关系</label>
                            <div class="col-sm-10 col-md-4">
                                <input id="emergency_contact_relation" name="emergency_contact_relation"
                                       value="{$data.emergency_contact_relation|default=''}" placeholder="请输入与本人关系"
                                       type="text" class="form-control field-text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="emergency_contact_mobile" class="col-sm-2 control-label">联系人电话</label>
                            <div class="col-sm-10 col-md-4">
                                <input id="emergency_contact_mobile" name="emergency_contact_mobile"
                                       value="{$data.emergency_contact_mobile|default=''}" placeholder="请输入联系人电话"
                                       type="text" type="tel" maxlength="11"  class="form-control field-text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="marriage" class="col-sm-2 control-label">是否已婚</label>
                            <div class="col-sm-10 col-md-4">
                                <input class="input-switch" id="marriage" value="1" {if(!isset($data)
                                       ||$data.marriage==1)}checked{/if} type="checkbox"/>
                                <input class="switch field-switch" placeholder="是否已婚" name="marriage"
                                       value="{$data.marriage|default='1'}" hidden/>
                            </div>
                        </div>

                        <script>
                            $('#marriage').bootstrapSwitch({
                                onText: "是",
                                offText: "否",
                                onColor: "success",
                                offColor: "danger",
                                onSwitchChange: function (event, state) {
                                    $(event.target).closest('.bootstrap-switch').next().val(state ? '1' : '0').change();
                                }
                            });
                        </script>
                        <div class="form-group">
                            <label for="education_level" class="col-sm-2 control-label">文化程度</label>
                            <div class="col-sm-10 col-md-4">
                                <input id="education_level" name="education_level"
                                       value="{$data.education_level|default=''}" placeholder="请输入文化程度" type="text"
                                       class="form-control field-text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="education_school" class="col-sm-2 control-label">毕业学校</label>
                            <div class="col-sm-10 col-md-4">
                                <input id="education_school" name="education_school"
                                       value="{$data.education_school|default=''}" placeholder="请输入毕业学校" type="text"
                                       class="form-control field-text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="major" class="col-sm-2 control-label">专业</label>
                            <div class="col-sm-10 col-md-4">
                                <input id="major" name="major" value="{$data.major|default=''}" placeholder="请输入专业"
                                       type="text" class="form-control field-text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="domicile" class="col-sm-2 control-label">户籍所在地</label>
                            <div class="col-sm-10 col-md-4">
                                <input id="domicile" name="domicile" value="{$data.domicile|default=''}"
                                       placeholder="请输入户籍所在地" type="text" class="form-control field-text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="current_address" class="col-sm-2 control-label">现家庭住址</label>
                            <div class="col-sm-10 col-md-4">
                                <input id="current_address" name="current_address"
                                       value="{$data.current_address|default=''}" placeholder="请输入现家庭住址" type="text"
                                       class="form-control field-text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="card_num" class="col-sm-2 control-label">开户行</label>
                            <div class="col-sm-10 col-md-4">
                                <input id="bank" name="bank" value="{$data.bank|default=''}"
                                       placeholder="请输入开户行" type="text" class="form-control field-text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="card_num" class="col-sm-2 control-label">银行卡号</label>
                            <div class="col-sm-10 col-md-4">
                                <input id="card_num" name="card_num" value="{$data.card_num|default=''}"
                                       placeholder="请输入银行卡号" type="text" class="form-control field-text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="card_name" class="col-sm-2 control-label">发放工资姓名</label>
                            <div class="col-sm-10 col-md-4">
                                <input id="card_name" name="card_name" value="{$data.card_name|default=''}"
                                       placeholder="请输入发放工资姓名" type="text" class="form-control field-text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="days_per_month" class="col-sm-2 control-label">每月工作天数</label>
                            <div class="col-sm-10 col-md-4">
                                <div class="input-group">
                                    <input id="days_per_month" name="days_per_month" value="{$data.days_per_month|default='24'}" placeholder="请输入每月工作天数" type="number" class="form-control field-number">
                                </div>
                            </div>
                        </div>
<!--                        <script>-->
<!--                            $('#days_per_month')-->
<!--                                .bootstrapNumber({-->
<!--                                    upClass: 'success',-->
<!--                                    downClass: 'primary',-->
<!--                                    center: true-->
<!--                                });-->
<!--                        </script>-->
                        <div class="form-group">
                            <label for="hours_per_day" class="col-sm-2 control-label">每天工作(时)</label>
                            <div class="col-sm-10 col-md-4">
                                <div class="input-group">
                                    <input id="hours_per_day" name="hours_per_day" value="{$data.hours_per_day|default='8'}" placeholder="请输入每天工作(时)" type="number" class="form-control field-number">
                                </div>
                            </div>
                        </div>
<!--                        <script>-->
<!--                            $('#hours_per_day')-->
<!--                                .bootstrapNumber({-->
<!--                                    upClass: 'success',-->
<!--                                    downClass: 'primary',-->
<!--                                    center: true-->
<!--                                });-->
<!--                        </script>-->

                        <div class="form-group">
                            <label for="status" class="col-sm-2 control-label">是否启用</label>
                            <div class="col-sm-10 col-md-4">
                                <input class="input-switch" id="status" value="1" {if(!isset($data)
                                       ||$data.status==1)}checked{/if} type="checkbox"/>
                                <input class="switch field-switch" placeholder="是否启用" name="status"
                                       value="{$data.status|default='1'}" hidden/>
                            </div>
                        </div>

                        <script>
                            $('#status').bootstrapSwitch({
                                onText: "是",
                                offText: "否",
                                onColor: "success",
                                offColor: "danger",
                                onSwitchChange: function (event, state) {
                                    $(event.target).closest('.bootstrap-switch').next().val(state ? '1' : '0').change();
                                }
                            });
                        </script>
                    </div>
                    <!-- 表单底部 -->
                    <div class="box-footer">
                        {:token()}
                        <div class="col-sm-2">
                        </div>
                        <div class="col-sm-10 col-md-4">
                            {if !isset($data)}
                            <div class="btn-group pull-right">
                                <label class="createContinue">
                                    <input type="checkbox" value="1" id="_create" name="_create"
                                           title="继续添加数据">继续添加</label>
                            </div>
                            {/if}
                            <div class="btn-group">
                                <button type="submit" class="btn flat btn-info dataFormSubmit">
                                    保存
                                </button>
                            </div>
                            <div class="btn-group">
                                <button type="reset" class="btn flat btn-default dataFormReset">
                                    重置
                                </button>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</section>
<script src="/static/admin/js/card.js"></script>
<script src="/static/admin/js/yinhangka.js"></script>

<script>
    /** 表单验证 **/
    var url = window.location.href;
    var flag = true;
    if (url.indexOf('edit')>=0){
        flag = false;
    }
    // 身份证号码验证
    jQuery.validator.addMethod("isIdCardNo", function(value, element) {
        return this.optional(element) || idCardNoUtil.checkIdCardNo(value);
    }, "请正确输入您的身份证号码");
    //身份证输入获取用户生日信息
    jQuery('#id_card').change(function (e) {
        let info =  idCardNoUtil.getIdCardInfo($(this).val());
        let gender = info.gender;
        let yue = info.yue;
        let birthday = info.birthday;
        let age = info.age;
        $("input[name='sex'][value="+gender+"]").prop("checked",true);
        $("input[name='age']").val(age);
        $("input[name='birthday_month']").val(yue);
        $("input[name='birthday']").val(birthday);
    });

    $('#card_num').change(function () {
        var account = $("#card_num").val();
        window.Bank.getBankBin(account,function (e,bin) {

            if (e != null){
                layer.alert(e,{icon:0})
                return false;
            }
            if (bin != undefined){
                if (bin.bankCode != 'ICBC'){
                    layer.alert('输入的不是工商银行卡号哦',{icon:0});
                    return false;
                }
            }
        });

    });

    //手机号格式验证
    jQuery.validator.addMethod("isMobile", function(value, element) {
        var length = value.length;
        var mobile = /^1[3456789]\d{9}$/;
        return this.optional(element) || (length == 11 && mobile.test(value));
    }, "请正确填写您的手机号码");
    //手机号唯一验证
    jQuery.validator.addMethod("uniqueMobile", function(value, element) {
        var resultval = false;
        jQuery.ajax({
            type: 'post',
            async:false,
            data:{'mobile':value},
            url: "{:url('staff/uniqueMobile')}",
            dataType: 'json',
            success: function (result) {
                if (result.code == 0) {
                    resultval = false;
                }
                else {
                    resultval = true;
                }
            },
            error: function () {
            }
        });
        return this.optional(element) || resultval;
    }, "手机号已经存在");
    /** 表单验证 **/
    $('#dataForm').validate({
        rules: {
            'name': {
                required: true,
            },
            'insure_id':{
                required:true
            },
            'position_id': {
                required: true,
            },
            'insurance': {
                required: true,
            },

            'mobile': {
                required: true,
                uniqueMobile:flag,
                isMobile:true,
            },
            'department_id': {
                required: true,
            },
            'id_card': {
                required: true,
                isIdCardNo:true
            },

        },
        messages: {
            'name': {
                required: "姓名不能为空",
            },
            'position_id': {
                required: "职位不能为空",
            },
            'insure_id': {
                required: "社保关系不能为空",
            },
            'mobile': {
                required: "手机号不能为空",
                isMobile: '请填写正确的手机号',
                uniqueMobile: '手机号已经存在',
            },
            'department_id': {
                required: "部门不能为空",
            },
            'id_card': {
                required: "身份证号不能为空",
            },

        }
    });

    function getMonthBeforeFormatAndDay(dates,num, format, day) {
        var date = new Date(dates);
        date.setMonth(date.getMonth() + (num*1), 1);
        //读取日期自动会减一，所以要加一
        var mo = date.getMonth() + 1;
        //小月
        if (mo == 4 || mo == 6 || mo == 9 || mo == 11) {
            if (day > 30) {
                day = 30
            }
        }
        //2月
        else if (mo == 2) {

            if (isLeapYear(date.getFullYear())) {
                if (day > 29) {
                    day = 29
                }
            }else {
                if (day > 28) {
                    day = 28
                }
            }
        }
        //大月
        else {
            if (day > 31) {
                day = 31
            }
        }
        retureValue = date.format('yyyy' + format + 'MM' + format + day);

        return retureValue;
    }

    //JS判断闰年代码
    function isLeapYear(Year) {
        if (((Year % 4) == 0) && ((Year % 100) != 0) || ((Year % 400) == 0)) {
            return (true);
        } else { return (false); }
    }

    //日期格式化
    Date.prototype.format = function (format) {
        var o = {
            "M+": this.getMonth() + 1, // month
            "d+": this.getDate(), // day
            "h+": this.getHours(), // hour
            "m+": this.getMinutes(), // minute
            "s+": this.getSeconds(), // second
            "q+": Math.floor((this.getMonth() + 3) / 3), // quarter
            "S": this.getMilliseconds()
            // millisecond
        }

        if (/(y+)/.test(format))
            format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
        for (var k in o)
            if (new RegExp("(" + k + ")").test(format))
                format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));
        return format;
    }
</script>
{/block}